package com.charging.serviceImpl;

import cn.hutool.http.HttpUtil;
import com.charging.bean.ApiDiscount;
import com.charging.bean.Constent;
import com.charging.bean.Site;
import com.charging.bean.layuiBean.ResultPage;
import com.charging.bean.layuiBean.VoPage;
import com.charging.mapper.ApiDiscountMapper;
import com.charging.mapper.SiteMapper;
import com.charging.service.ApiDiscountService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.charging.service.SiteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 冯政尚
 * @since 2019-09-23
 */
@Service
public class ApiDiscountServiceImpl extends ServiceImpl<ApiDiscountMapper, ApiDiscount> implements ApiDiscountService {


    @Autowired
    SiteMapper siteMapper;

    @Override
    public ResultPage<ApiDiscount> selectMyPage(VoPage voPage) {
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("page", (voPage.getPage() - 1) * voPage.getLimit());
        paramMap.put("limit", voPage.getLimit());
        List<ApiDiscount> list = baseMapper.selectMyPage(paramMap);
        System.out.println("list:"+list);
        Integer count = baseMapper.countMyPage(paramMap);
        ResultPage<ApiDiscount> resultPage = new ResultPage<>();
        resultPage.setCode(0);
        resultPage.setCount(count);
        resultPage.setMsg("成功");
        resultPage.setData(list);
        return resultPage;
    }

//    @Override
//    public ResultPage selectSiteApi(VoPage voPage) {
//        Map<String, Object> paramMap = new HashMap<String, Object>();
//        paramMap.put("page", (voPage.getPage() - 1) * voPage.getLimit());
//        paramMap.put("limit", voPage.getLimit());
//        List<Site> siteList = siteMapper.selectMyPage(paramMap);
//        String result =  HttpUtil.get(Constent.CHARGE_API_URL);
//
//
//        return null;
//    }

}
